<%@ page pageEncoding="UTF-8" %>
<script src="<c:url value='/resources/js/manage.js'/>"></script>
<c:import url="../../../template/layout.jsp" charEncoding="UTF-8">
  <c:param name="title" value="招聘列表"/>
  <c:param name="body">

    <div class="content-title">招聘列表
      <p>${message.msg}</p>
    </div>
    <div class="container"
         style="background-color:#DCEAF4; width:1300px; height:500px;border-radius: 0px 0px 0px 0px;">
      <c:if test="${message!=null}">
        <div class="alert alert-danger" role="alert">${message.msg}</div>
      </c:if>
      <div class="btn-group pull-right" style="margin-bottom:8px;">
        <a class="btn btn-lg btn-primary" href="${pageContext.request.contextPath}/system/recruitment/edit">
          <span class="glyphicon"></span> 添加招聘启事
        </a>
      </div>
      <p></p> <div class="col-sm-5 col-sm-offset-1">
      <form id="searchForm" method="get" action="/system/recruitment/list"
            name="user">
        <div class="input-group">
          <input id="pageNo" name="pageNo" type="hidden" value="${pager.pageNo}"/>
          <input id="pageSize" name="pageSize" type="hidden" value="${pager.pageSize}"/>


        </div>
      </form>
    </div>

      <div class="main-content">

        <table class="table">
          <thead>
          <tr>
            <th>职位</th>
            <th>职位要求</th>
            <th>薪资</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <c:forEach items="${pager.list}" var="recruitment">
            <tr class="success">
              <td>${recruitment.position}</td>
              <td>${recruitment.request}</td>
              <td>${recruitment.treatment}</td>

              <td>
                <button onclick="editRecruitment('<c:url value="/system/recruitment/getRecruitment?id=${recruitment.id}"/>')"<%----%>
                        class="btn btn-primary btn-xs"
                        data-toggle="modal" data-target="#editRecruitment">编辑
                </button>
                &nbsp;&nbsp;
                <button class="btn btn-primary btn-xs"
                        href="javascript:void(0)" data-toggle="tooltip" title="删除"
                        onclick="if (confirm('确认要删除本记录吗？此操作将不可恢复！'))
                                location = '<c:url
                                value="/system/recruitment/delete?id=${recruitment.id}"/>';
                                return false;">删除
                </button>


              </td>
            </tr>
          </c:forEach>
          </tbody>
        </table>
      </div>
      <div class="row">
        <div class="col-sm-12">
            ${pager}
        </div>
      </div>
    </div>
    <script type="text/javascript">

      function editRecruitment(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (recruitment) {
            $('#edit_id').val(recruitment.id);
            $('#edit_position').val(recruitment.position);
            $('#edit_request').val(recruitment.request);/**/
            $('#edit_treatment').val(recruitment.treatment);
            $('#edit_positionType').val(recruitment.positionType);
            $('#edit_num').val(recruitment.num);
            $('#edit_workPosition').val(recruitment.workPosition);
            $('#edit_jobAttribute').val(recruitment.jobAttribute);
            $('#edit_department').val(recruitment.department);
            $('#edit_phone').val(recruitment.phone);/**/
            $('#edit_responsibility').val(recruitment.responsibility);
          }
        });
      }


    </script>
    <%--编辑修改模态框--%>
    <div class="modal fade" id="editRecruitment" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">编辑</h3>
          </div>
          <div class="modal-body">
            <form action="/system/recruitment/update" method="POST">
              <div class="form-group">
              <label class="control-label" for="edit_position">职位</label>
              <input type="text" class="form-control" id="edit_position" name="position"
                     required>
            </div>
              <div class="form-group">
                <label for="edit_request">职位要求</label>
                <input class="form-control" id="edit_request" name="request" required/>
              </div>
              <div class="form-group">
                <label for="edit_treatment">待遇</label>
                <input class="form-control" id="edit_treatment" name="treatment" required/>
              </div>

              <div class="form-group">
                <label for="edit_positionType">职位类型</label>
                  <input type="text" class="form-control" id="edit_positionType" name="positionType" required>
              </div>
              <div class="form-group">
                <label for="edit_responsibility">职责</label>
                  <input type="text" class="form-control" name="responsibility" id="edit_responsibility" required/>
              </div>

              <div class="form-group">
                <label for="edit_num">所需人数</label>
                  <input type="text" class="form-control" id="edit_num" name="num" required/>
              </div>
              <div class="form-group">
                <label for="edit_workPosition">工作地点</label>
                  <select class="form-control" name="workPosition" id="edit_workPosition" required>
                    <option value="上海">上海</option>
                    <option value="广州">广州</option>
                    <option value="北京">北京</option>
                    <option value="成都">成都</option>
                    <option value="深圳">深圳</option>
                    <option value="杭州">杭州</option>
                    <option value="天津">天津</option>
                  </select>
              </div>
              <div class="form-group">
                <label for="edit_jobAttribute">工作属性</label>
                  <select class="form-control" name="jobAttribute" id="edit_jobAttribute" required>
                    <option value="全职">全职</option>
                    <option value="兼职">兼职</option>
                  </select>
              </div>
              <div class="form-group">
                <label for="edit_department">部门</label>
                  <input type="text" class="form-control" name="department" id="edit_department" required/>
              </div>
              <div class="form-group">
                <label for="edit_phone">电话</label>
                  <input type="text" class="form-control" id="edit_phone" name="phone" required/>
              </div>
              <div class="form-group">
                <input class="form-control" type="hidden" name="id" id="edit_id"/>
              </div>
              <button class="btn btn-primary btn-lg btn-block" type="submit">
                确定
              </button>
            </form>
          </div>
        </div>
      </div>
    </div>
  </c:param>
</c:import>
